"""Stack URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.urls import path
from rest_framework.routers import SimpleRouter

from .views import ConvBondView, StackView, FundView
from .views import HTMLTest
from .views import Health, HTMLHongKongStack, HTMLLOFFund, HTMLConvFond, \
    FundViewSet, StackViewSet, GetRefreshStack, ConvBondViewSet, GetRefreshFund
from .views import SaveStack, SaveConvBond, SaveFund

router = SimpleRouter()

router.register('api/stack', StackViewSet, basename="fundview")
router.register('api/fund', FundViewSet, basename="stackview")
router.register('api/convbond', ConvBondViewSet, basename="convbondview")

urlpatterns = [
    path('api/stack_data/', StackView.as_view()),
    path('api/convbond_data/', ConvBondView.as_view()),
    path('api/fund_data/', FundView.as_view()),
    path('api/health/', Health.as_view(), name='health'),
    path('api/refresh_stack/', GetRefreshStack.as_view()),
    path('api/refresh_fund/', GetRefreshFund.as_view()),

    # 存储数据到缓存
    path('post/fund/', SaveFund.as_view()),
    path('post/stack/', SaveStack.as_view()),
    path('post/convbond/', SaveConvBond.as_view()),

    # HTML页面
    path('stack/', HTMLHongKongStack),
    path('fund/', HTMLLOFFund),
    path('convbond/', HTMLConvFond),

    # TEST页面
    path('test/', HTMLTest),

    # sqlite数据
    url('^', include(router.urls))
]
